<?php
import("@.Validator.Validator");

class UserValidator extends Validator
{
    //登录时校验
    private static $loginRules = array(
        array('acct_no', 'require', 'acct_no is null'), //账户号是否为空检测
        array('acct_no', 'checkAcctNo', 'acctNo pattern not right', Model::EXISTS_VALIDATE, 'callback', Model::MODEL_BOTH),//账户号格式检测
        array('psd', 'require', 'password is null'), // 密码是否为空检测
        array('psd', '8,16', 'password length not right', Model::EXISTS_VALIDATE, 'length', Model::MODEL_BOTH), //密码格式检测
        array('psd', 'checkPsd', 'psd pattern not right', Model::EXISTS_VALIDATE, 'callback', Model::MODEL_BOTH), //密码格式检测
    );

    //注册新账户校验
    private static $registerRules = array(
        array('tel', 'require', 'tel is null'), //手机号是否为空检测
        array('tel', 'checkTel', 'tel pattern not right or tel has existed', Model::EXISTS_VALIDATE, 'callback', Model::MODEL_BOTH),//手机号格式检测
        array('tel', '', 'tel has been registered', Model::EXISTS_VALIDATE, 'unique', Model::MODEL_BOTH),//手机号是否唯一检测
        array('psd', 'require', 'password is null'), // 密码是否为空检测
        array('psd', '8,16', 'password length not right', Model::EXISTS_VALIDATE, 'length', Model::MODEL_BOTH), //密码格式检测
        array('psd', 'checkPsd', 'psd pattern not right', Model::EXISTS_VALIDATE, 'callback', Model::MODEL_BOTH), //密码格式检测
    );

    //获取登录校验规则
    final public static function getLoginRules()
    {
        return UserValidator::$loginRules;
    }

    //获取注册校验规则
    final public static function getRegisterRules()
    {
        return UserValidator::$registerRules;
    }
}

?>